package com.hujing.io;

import org.springframework.util.StreamUtils;

import java.io.FileOutputStream;
import java.io.InputStream;

/**
 * @Author : hujing
 * @Date: 2025/7/22 15:15
 * @Description:
 */
public class FileOutputStreamDemo {

    public static void main(String[] args) {
        // 复制文件知识搜索.txt
        try(InputStream is = FileOutputStreamDemo.class.getClassLoader().getResourceAsStream("知识搜索.txt");
            FileOutputStream fos = new FileOutputStream("知识搜索副本.txt")){
            if (is == null){
                System.out.println("文件不存在");
                return;
            }
            StreamUtils.copy(is, fos);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
